<template>
  <view style="padding-bottom: 2vh;">
    <view class="cu-list menu-avatar" >
		<view class="cu-list menu-avatar" style="margin-bottom: 53px;">
		  <view
		    v-for="(schedule,index) in courseLists" 
		    :key="index" 
		    class="cu-item"
		    :data-courseid="schedule.fdId"
			:data-states="schedule.check"
		    @tap="courseInfos"
			style="height: 220upx;"
			>
		    <view class="cu-avatar round lg bg-cyan">课</view>
		    <view class="content">
		      <view class="text-grey">
				  {{ schedule.fdSubjectName}}
			  </view>
		      <view class="text-gray text-sm flex">
		        <view class="text-cut">
					<block v-for="(item,index) in schedule.fdTeacherNames">
						<view class="cu-tag round bg-orange sm">{{ item }}</view>
					</block>
				</view>
		      </view>
		    </view>
		    <view class="action">
		      <view v-show="schedule.check" class="cu-tag round bg-red sm">签</view>
		    </view>
		  </view>
		  <block v-if="courseLists == ''">
		    <view class="stern" style="text-align: center; margin: 30rpx 0rpx;">没有更多了...</view>
		  </block>
			
		</view>
    </view>
	
	
	<!-- 评论评价 -->
	<view class="cu-modal" :class="modalEvaluate == 'modalEvaluate'?'show':''">
	  <view class="cu-dialog">
		  <view class="cu-bar bg-white justify-end">
		    <view class="content">课程评价</view>
		    <view class="action" @tap="hideModal">
		  	<text class="cuIcon-close text-red" />
		    </view>
		  </view>
		  <textarea maxlength="-1" :disabled="modalName!=null" @input="textareaBInput" placeholder="请输入评价内容..."></textarea>
		  <view class="cu-bar bg-white justify-end">
		    <view class="action">
			   <button class="cu-btn bg-gray margin-left" @tap="hideModal">取消</button>
 		       <button class="cu-btn bg-green margin-left" @tap="evaluate">提交</button>
		    </view>
		  </view>
	  </view>
	</view>
		
    <!-- 二维码弹框 -->
    <view class="cu-modal" v-if="courseInfo != ''" :class="modalName != null ?'show':''">
      <view class="cu-dialog">
        <!-- 课程信息 -->
        <view class="cu-bar bg-white justify-end">
          <view class="content">{{ courseInfo.fdSubjectName }}</view>
        </view>
        <view v-if="courseInfo.fdRemarks" class="padding-xl">
          {{ courseInfo.fdRemarks }}
        </view>
        <!-- 二维码 -->
        <tki-qrcode
          ref="qrcode"
          :val="val"
          :size="size"
          :background="background"
          :foreground="foreground"
          :pdground="pdground"
          :lv="lv" 
          :onval="onval"
          :load-make="loadMake" />
		  
		  <view class="padding-x">
		    code: {{ courseInfo.fdId }}
		  </view>
		<view class="padding-xl">
		  {{ courseInfo.fdSubjectStartTime }} <p>
		  Address: {{ courseInfo.fdClassroomAddress }}</p>
		</view>
		
        <!-- <view class="bg-img" style="background-image: url('https://ossweb-img.qq.com/images/lol/web201310/skin/big91012.jpg');height:200px;" /> -->
        <view class="cu-bar bg-white">
          <view class="action margin-0 flex-sub  solid-left" @tap="hideModal">关闭</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
	import { getMyCourse } from 'api/myCourse/index'
	import tkiQrcode from '@/components/tki-qrcode/tki-qrcode.vue'
	
	export default {
	components: { tkiQrcode },
	data() {
		return {
			val: '',
			size: 400,
			unit: 'unit',
			background: '#ffffff',
			foreground: '#000000',
			pdground: '#000000',
			iconSize: 45,
			lv: 3,
			onval: true,
			loadMake: true,
			modalName: null,
			courseLists: [],
			courseInfo: '',
			modalEvaluate: null,
			PageCur: 'basics',
			WindowHeight: 812
			}
		},
		created() {
			getMyCourse(uni.getStorageSync('userId')).then(res => {
				console.log(res.data)
				if (res.data != null) {
					this.courseLists = res.data
				}
			}).catch(err => {
				console.log(err)
			})
		},
		methods: {
			evaluate(){
				
			},
			NavChange: function(e) {
				this.PageCur = e.currentTarget.dataset.cur
			},
			courseInfos(e) {
				if(e.currentTarget.dataset.states==1) {
					this.modalEvaluate = 'modalEvaluate'
				} else {
					// 弹二维码框
					this.modalName = e.currentTarget.dataset.courseid
					this.val = e.currentTarget.dataset.courseid
					for (const val in this.courseLists) {
						if (this.modalName == this.courseLists[val].fdId) {
							this.courseInfo = this.courseLists[val]
						}
					}
				}
			},
			hideModal(e) {
				this.modalName = null
				this.modalEvaluate = null
			}
		}
	}
</script>

<style>
	
</style>
